package com.auction.controller.user;

import com.auction.pojo.Result;
import com.auction.service.AuctionService;
import com.auction.vo.AuctionVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController("userAuctionController")
@RequestMapping("/user/auction")
public class AuctionController {

    @Autowired
    private AuctionService auctionService;

    /**
     * 根据分类id查询拍卖品列表
     * 
     * @param categoryId
     * @return
     */
    @GetMapping("/list")
    public Result<List<AuctionVO>> list(Long categoryId) {
        log.info("按分类id查询拍卖品列表：categoryId={}", categoryId);
        List<AuctionVO> list = auctionService.list(categoryId);
        return Result.success(list);
    }

    /**
     * 获取拍卖品详情
     *
     * @param id 拍卖品ID
     * @return 拍卖品详情
     */
    @GetMapping("/{id}")
    public Result<AuctionVO> getById(@PathVariable Long id) {
        log.info("获取拍卖品详情：id={}", id);
        AuctionVO auctionVO = auctionService.getByIdVO(id);
        return Result.success(auctionVO);
    }
}